package com.liwei.log4jtest;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Lo4jTest1 {

    private static String CLASS_NAME1 = "com.liwei.log4jtest.Lo4jTest1";
    private static String CLASS_NAME2 = "com.liwei.log4jtest.Lo4jTest2";
    private static Logger log1        = Logger.getLogger(CLASS_NAME1);
    private static Logger log2        = Logger.getLogger(CLASS_NAME2);

    private static String profile     = "log4j.properties";

    public static void main(String[] args) {

        /*	 在这个例子中
        	 com.liwei.log4jtest.Lo4jTest1这个logger的信息输出到bd2.log文件，
        	 同时我们定义log4j.additivity.com.liwei.log4jtest.Lo4jTest1=false，
        	 使得它的信息不传送到rootLogger
        	 
        	 com.liwei.log4jtest.Lo4jTest2这个logger的信息输出到bd3.log文件，
        	 我们没有关闭它，所以它的信息输出到了rootLogger
         */
        PropertyConfigurator.configure(profile);

        log1.debug("11111111111111Log4j Debug.");
        log1.error("11111111111111Log4j Error.");
        log1.warn("11111111111111Log4j Warn.");
        log1.info("11111111111111Log4j Info.");
        log1.fatal("11111111111111Log4j Fatal.");

        log2.debug("222222222222Log4j Debug.");
        log2.error("222222222222Log4j Error.");
        log2.warn("222222222222Log4j Warn.");
        log2.info("222222222222Log4j Info.");
        log2.fatal("222222222222Log4j Fatal.");

    }
}
